﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HighDiveEngine.Resources;

namespace HighDiveAdmin.GUI.Components
{
    public partial class EditContestDetailsPanel : UserControl
    {
        public EditContestDetailsPanel()
        {
            InitializeComponent();
        }

        internal void FillDetails(HighDiveEngine.Model.Contest contest)
        {
            textBoxName.Text = contest.Name;
            textBoxCity.Text = contest.City;
            textBoxClub.Text = contest.Club;
            textBoxCountry.Text = contest.Country;
        }

        public bool ContestLoaded()
        {
            if (textBoxName.Text.Length > 0)
                return true;
            return false;
        }

        public void Clear()
        {
            textBoxName.Text = "";
            textBoxCity.Text = "";
            textBoxClub.Text = "";
            textBoxCountry.Text = "";
        }

        public string GetName()
        {
            return textBoxName.Text;
        }

        public ContestArgs GetContestArgs()
        {
            return new ContestArgs()
            {
                City = textBoxCity.Text,
                Country = textBoxCountry.Text,
                Club = textBoxClub.Text,
                Date = datePicker.Value,
                Name = textBoxName.Text,
                Time = TimePicker.Value
            };
        }

        #region TabStop
        private void EditContestDetailsPanel_TabStopChanged(object sender, EventArgs e)
        {
            foreach (Control control in Controls)
                control.TabStop = TabStop;
            if (TabStop)
                textBoxName.Focus();
        }

        private void EditContestDetailsPanel_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
                textBoxName.Focus();
        }
        #endregion
    }
}
